﻿// 项目：	Guan.CMS.Web - Guan.CMS
// 文件名：	SystemInfoController.cs
// 
// 修改时间：2013-03-08 23:20
// 修改人：	Cooclsee

using System;
using System.Runtime.InteropServices;
using System.Web.Mvc;
using Guan.CMS.Web.Core.ActionFilters;
using Guan.CMS.Web.Core.Models;
using Guan.CMS.Web.ViewModels;

namespace Guan.CMS.Web.Areas.Admin.Controllers
{
    [CmsAuthorize(Roles.Admin)]
    [CompressResponse]
    public class SystemInfoController : Controller
    {
        //
        // GET: /Admin/SystemInfo/

        public ActionResult Index()
        {
            return RedirectToAction("Version");
        }

        [OutputCache(Duration = 3600)]
        public ActionResult Version()
        {
            var model = new SystemVersionViewModel
            {
                Version = "v1.0",
                ServerTimeZone = TimeZone.CurrentTimeZone.StandardName,
                ServerLocalTime = DateTime.Now,
                UtcTime = DateTime.UtcNow
            };
            try
            {
                model.OperatingSystem = Environment.OSVersion.VersionString;
            }
            catch
            {
            }
            try
            {
                model.AspNetInfo = RuntimeEnvironment.GetSystemVersion();
            }
            catch (Exception)
            {
            }
            try
            {
                model.IsFullTrust = AppDomain.CurrentDomain.IsFullyTrusted.ToString();
            }
            catch (Exception)
            {
            }

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                model.LoadedAssemblies.Add(new SystemVersionViewModel.LoadedAssembly() {FullName = assembly.FullName,});
            }
            return View(model);
        }
    }
}